package com.example.demo.main;

import android.content.Context;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;


public class SectionsPagerAdapter extends FragmentPagerAdapter {

    private static final String[] TAB_TITLES = {"推荐", "热点", "电影","电视剧", "综艺", "体育"};
    private final Context mContext;

    public SectionsPagerAdapter(Context context, FragmentManager fm)
    {
        super(fm);
        mContext = context;
    }

    // 返回对应的Fragment
    @Override
    public Fragment getItem(int position)
    {
        return PlaceholderFragment.newInstance(TAB_TITLES[position]);
    }

    // 获取Tab显示的标题
    @Nullable
    @Override
    public CharSequence getPageTitle(int position)
    {
        return TAB_TITLES[position];
    }

    @Override
    public int getCount()
    {
        return TAB_TITLES.length;
    }
}
